<?php

namespace app\adminapi\controller\setting\lang;

use app\adminapi\controller\BaseAdminApiController;
use app\adminapi\logic\setting\lang\ConfigLogic;
use app\adminapi\validate\setting\lang\ConfigValidate;

/**
 * 语言控制器
 * Class LanguasController
 * @package app\adminapi\controller\setting
 */
class ConfigController extends BaseAdminApiController
{

    /**
     * @notes 获取翻译配置
     * @return \support\Response
     */
    public function getConfig()
    {
        $result = ConfigLogic::getTranslateConfig();
        return $this->data($result);
    }

    /**
     * @notes 获取翻译配置详情
     * @return \support\Response
     */
    public function getConfigDetail()
    {
        $params = (new ConfigValidate())->goCheck('detail');
        $result = ConfigLogic::detail($params);
        return $this->data($result);
    }

    /**
     * @notes 设置翻译配置
     * @return \support\Response
     */
    public function setConfig()
    {
        $params = (new ConfigValidate())->post()->goCheck('setConfig');
        $result = ConfigLogic::setTranslateConfig($params);
        if (true === $result) {
            return $this->success('保存成功', [], 1, 1);
        }
        return $this->fail(ConfigLogic::getError());
    }

}
